package com.baizhi.mall.controller;

import com.baizhi.mall.util.ResultEntity;
import org.hibernate.validator.constraints.Length;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

@Validated
@RestController
@RequestMapping("jsr303")
public class JSR303Controller {

    @GetMapping("testPrimitive")
    public ResultEntity testPrimitive(
            @NotNull(message="用户名不能为空") String username,
            @NotNull(message = "密码不能为空")
            @Length(min=6,message = "密码长度不能少于6位")
                    String password
    ){
        System.out.println("username = " + username + ", password = " + password);
        return ResultEntity.ok();
    }

}
